library(SDMTools)

work.dir = "H:/Barra Work Directory/bioclim/"; setwd(work.dir)

bc12 = read.asc.gz('H:/Barra Work Directory/bioclim/bioclim_12.asc.gz')

#create the images
#indicate the position of the legend in lats and longs
pnts=cbind(x=c(115,118,118,115), y=c(-10,-10,-15,-15))
cols = colorRampPalette(c('tan', 'lightblue', 'slateblue', 'blue', 'blue4', 'black'))(101)
png(paste('bc12.png',sep=''), width=7, height=7, units='cm', res=300, pointsize=5, bg='white')
	image(bc12,ann=FALSE,axes=FALSE,col=cols)
  legend.gradient(pnts,cols=cols,limits=range(bc12, na.rm=T), title='Annual Precipitation')
dev.off()
